#include "optionswidget.h"
#include "filetable.h"
#include "slepui.h"

void OptionsWidget::createInputTab(){
    QLayout *layout = new QVBoxLayout(this);
    QWidget *inputWidget = new QWidget(this);
    inputWidget->setLayout(layout);
    tabWidget->addTab(inputWidget,tr("Input"));

    QGroupBox *box = new QGroupBox;
    QVBoxLayout *inputLayout = new QVBoxLayout;

	QGroupBox *boxRandomData = new QGroupBox;
	QHBoxLayout *layoutBoxRandomData = new QHBoxLayout ;
	checkBoxRandomData = new QCheckBox(tr("Use random data"));
	checkBoxRandomData->setChecked(true);
	dimension1 = new QSpinBox;
	dimension2 = new QSpinBox;
	dimension1->setSingleStep(100);
	dimension2->setSingleStep(100);
	dimension1->setRange(10,1000000);
	dimension2->setRange(10,1000000);
	dimension1->setValue(1000);
	dimension2->setValue(1000);
	layoutBoxRandomData->addWidget(checkBoxRandomData);
	layoutBoxRandomData->addWidget(new QLabel(tr("( dimension ")));
	layoutBoxRandomData->addWidget(dimension1);
	layoutBoxRandomData->addWidget(new QLabel(tr(" x ")),0,Qt::AlignCenter);
	layoutBoxRandomData->addWidget(dimension2);
	layoutBoxRandomData->addWidget(new QLabel(tr(")")));
	boxRandomData->setLayout(layoutBoxRandomData);
	inputLayout->addWidget(boxRandomData);

	if(method == Method_Logistic_R || method == Method_Logistic_C || method == Method_nnLogistic_C || method == Method_nnLogistic_R || method == Method_glLogistic_R){
		QGroupBox *boxSWeight = new QGroupBox;
		QHBoxLayout *layoutBoxSWeight = new QHBoxLayout ;
		spinBoxsWeight1 = new QDoubleSpinBox;
		spinBoxsWeight2 = new QDoubleSpinBox;
		spinBoxsWeight1->setSingleStep(0.1);
		spinBoxsWeight1->setRange(0.0,100.0);
		spinBoxsWeight1->setValue(1.0);
		spinBoxsWeight2->setSingleStep(0.1);
		spinBoxsWeight2->setRange(0.0,100.0);
		spinBoxsWeight2->setValue(1.0);
		opts->sWeight[0] = opts->sWeight[1] = 1.0;
		setREGISTER(opts,SlepOPT_sWeight);
		layoutBoxSWeight->addWidget(new QLabel(tr("Weights for positive and negative samples : +ve")));
		layoutBoxSWeight->addWidget(spinBoxsWeight1);
		layoutBoxSWeight->addWidget(new QLabel(tr("-ve")),0,Qt::AlignRight);
		layoutBoxSWeight->addWidget(spinBoxsWeight2);
		boxSWeight->setLayout(layoutBoxSWeight);
		inputLayout->addWidget(boxSWeight);
		connect(spinBoxsWeight1,SIGNAL(valueChanged(double)),this,SLOT(setOPTS_sWeight1(double)));
		connect(spinBoxsWeight2,SIGNAL(valueChanged(double)),this,SLOT(setOPTS_sWeight2(double)));
	}

    tableFeatureMatrix = new FileTable;
    tableLabelVector = new FileTable;

	inputLayout->addWidget(new QLabel(tr("Data")));
    inputLayout->addWidget(tableFeatureMatrix);
    inputLayout->addWidget(new QLabel(tr("Labels")));
    inputLayout->addWidget(tableLabelVector);

	tableFeatureMatrix->setEnabled(false);
	tableLabelVector->setEnabled(false);
	connect(checkBoxRandomData,SIGNAL(clicked(bool)),tableFeatureMatrix, SLOT(setDisabled(bool)));
	connect(checkBoxRandomData,SIGNAL(clicked(bool)),tableLabelVector, SLOT(setDisabled(bool)));
	connect(checkBoxRandomData,SIGNAL(clicked(bool)),dimension1, SLOT(setEnabled(bool)));
	connect(checkBoxRandomData,SIGNAL(clicked(bool)),dimension2, SLOT(setEnabled(bool)));

	if(method== Method_glLeast_R || method== Method_glLogistic_R || method == Method_mtLeast_R || method == Method_mtLogistic_R){
		tableGroupIndices = new FileTable;
		inputLayout->addWidget(new QLabel(tr("Group info")));
		inputLayout->addWidget(tableGroupIndices);
		tableGroupIndices->setEnabled(false);
		connect(checkBoxRandomData,SIGNAL(clicked(bool)),tableGroupIndices, SLOT(setDisabled(bool)));
	}

	box->setLayout(inputLayout);
	layout->addWidget(box);
    ((QBoxLayout*)layout)->addStretch();
}
